package cn.edu.ctbu.dp02.api;

import cn.edu.ctbu.dp02.entity.Student;
import cn.edu.ctbu.dp02.service.StudentService;
import cn.edu.ctbu.dp02.vo.QueryObj;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.*;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController

@RequestMapping("/api/student")

public class StudentApiController {

    @Autowired
    private StudentService studentService;

    @GetMapping("/list")
    public List<Student> findAll() {

        List<Student> students = studentService.getAll();
        return students;
    }

    @PostMapping("/add")//
    public Student add(Student student) {

        return studentService.add(student);
    }

    @PutMapping("/update")//
    public Student update(Student student) {

        return studentService.update(student);
    }


    @DeleteMapping("/delete/{id}")//
    public void delete(@PathVariable Integer id) {

        studentService.delete(id);
    }
    // 这里应该调用服务层方法获取学生列表


}

